package com.cet.others.连点器;

import java.awt.*;
import java.awt.event.MouseEvent;
import java.security.SecureRandom;
import java.util.concurrent.TimeUnit;

/**
 * @program: algorithm
 * @description: 连点器
 * @author: 陈恩涛
 * @create: 2022-04-05 15:39
 **/
public class ContinousMouseClick {
    public static void main(String[] args) throws Exception {
        TimeUnit.SECONDS.sleep(3);

        Robot robot = new Robot();
        SecureRandom sr = new SecureRandom();

        while (true) {
            // 每次点击前摇，单位s
            double pre = sr.nextDouble() + 0.35;
            // System.out.println((long)(pre * 1000));

            // 鼠标点击到松开之间的时间，单位s
            double during = sr.nextDouble() + 0.15;
            // System.out.println((long)(during * 1000));

            TimeUnit.MILLISECONDS.sleep((long)(pre * 1000));
            robot.mousePress(MouseEvent.BUTTON1_DOWN_MASK);
            TimeUnit.MILLISECONDS.sleep((long)(during * 1000));
            robot.mouseRelease(MouseEvent.BUTTON1_DOWN_MASK);
        }
    }
}
